package st.bossbirdroom.lock_screen;

import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;


public class LockScreenReceiver extends DeviceAdminReceiver {

    final String LOCK_SCREEN_ACTION = "st.bossbirdroom.lockscreen";

    @Override
    public void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);

        catchActionAndDoSomething(context, intent);

    }

    @Override
    public void onEnabled(Context context, Intent intent) {

        super.onEnabled(context, intent);

        Debug.show("LockScreenReceiver : onEnabled");

//        LockScreenPreferencesSaver.saveBoolean(context, context.getString(R.string.lock_screen_preferences_tag), true);

    }

    @Override
    public void onDisabled(Context context, Intent intent) {

        super.onDisabled(context, intent);

        Debug.show("LockScreenReceiver : onDisabled");

//        LockScreenPreferencesSaver.saveBoolean(context, context.getString(R.string.lock_screen_preferences_tag), false);

    }


    protected void catchActionAndDoSomething(Context context, Intent intent) {
        if (intent != null) {
            String action = intent.getAction();
            Debug.show("LockScreenReceiver : " + action);
            if (action != null && action.equals(LOCK_SCREEN_ACTION)) {
                LockScreenManager.lockScreen(context);
            }
        }
    }
}
